/**
* 左边菜单
*/ 
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      <span>后台系统</span>
    </div>
	
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <i  :class="menu.icon"></i>
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">
        <!--  <i class="iconfont" :class="chmenu.icon"></i> -->
		<i :class="chmenu.icon"></i>
          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 1,
          icon: 'el-icon-s-home',
          menuname: '首页',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'el-icon-s-data',
              menuname: '数据统计',
              hasThird: 'N',
              url: 'home/index',
              menus: null
            }
          ]
        },
        {
          menuid:2,
          icon: 'el-icon-tickets',
          menuname: '项目管理',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 21,
              icon: 'el-icon-tickets',
              menuname: '房屋管理',
              hasThird: 'N',
              url: 'house/house',
              menus: null
            }, {
              menuid: 22,
              icon: 'el-icon-tickets',
              menuname: '房屋类型',
              hasThird: 'N',
              url: 'house/type',
              menus: null
            },
						{
						  menuid: 23,
						  icon: 'el-icon-tickets',
						  menuname: '楼栋表',
						  hasThird: 'N',
						  url: 'house/project',
						  menus: null
						}
          ]
        },
        {
          menuid: 3,
          icon: 'el-icon-s-grid',
          menuname: '广告',
          hasThird: null,
          url: null,
          menus: [
          /*  {
              menuid: 31,
              icon: 'el-icon-s-grid',
              menuname: '文章管理',
              hasThird: 'N',
              url: 'article/article',
              menus: null
            }, */
            {
              menuid: 32,
              icon: 'el-icon-picture',
              menuname: '广告管理',
              hasThird: 'N',
              url: 'sys/banner',
              menus: null
            }
          ]
        },
        {
          menuid: 4,
          icon: 'el-icon-guide',
          menuname: '预约',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 41,
              icon: 'el-icon-guide',
              menuname: '预约管理',
              hasThird: 'N',
              url: 'yuyue/yuyue',
              menus: null
            }
          ]
        },
        {
          menuid: 5,
          icon: 'el-icon-s-shop',
          menuname: '图片',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 51,
              icon: 'el-icon-s-comment',
              menuname: '图片分类',
              hasThird: 'N',
              url: 'image/category',
              menus: null
            },{
              menuid: 52,
              icon: 'el-icon-c-scale-to-original',
              menuname: '图片管理',
              hasThird: 'N',
              url: 'image/image',
              menus: null
            },
          ]
        },
		{
		  menuid: 6,
		  icon: 'el-icon-money',
		  menuname: '用户管理',
		  hasThird: null,
		  url: null,
		  menus: [
		    {
		      menuid: 61,
		      icon: 'el-icon-wallet',
		      menuname: '用户',
		      hasThird: 'N',
		      url: 'user/user',
		      menus: null
		    }
		  ]
		},
		{
		  menuid: 7,
		  icon: 'el-icon-user',
		  menuname: '记录',
		  hasThird: null,
		  url: null,
		  menus: [
		    {
		      menuid: 71,
		      icon: 'el-icon-user',
		      menuname: '邀请记录',
		      hasThird: 'N',
		      url: 'user/invite',
		      menus: null
		    },{
		      menuid: 72,
		      icon: 'el-icon-user-solid',
		      menuname: '提现记录',
		      hasThird: 'N',
		      url: 'user/tx',
		      menus: null
		    } 
		  ]
		},
		{
		  menuid: 7111,
		  icon: 'el-icon-user',
		  menuname: '设置',
		  hasThird: null,
		  url: null,
		  menus: [
		    {
		      menuid: 711112,
		      icon: 'el-icon-user',
		      menuname: '系统配置',
		      hasThird: 'N',
		      url: 'sys/sys',
		      menus: null
		    }/* ,{
		      menuid: 71113,
		      icon: 'el-icon-user-solid',
		      menuname: '测试数据',
		      hasThird: 'N',
		      url: 'charts/statistics',
		      menus: null
		    } */
		  ]
		}
      ],
      msg: 'success'
    }
          this.allmenu = res.data
    
    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>